package com.example.cm_utils

import android.content.Context


fun getStatusBarHeight(context: Context): Int {
    var result = dp2px(context, 37)
    try {
        val resourceId = context.resources.getIdentifier("status_bar_height", "dimen", "android")
        if (resourceId > 0) {
            result = context.resources.getDimensionPixelSize(resourceId)
        }
    } catch (_: Exception){}
    return result
}


fun dp2px(context: Context, dpValue: Int): Int {
    return (context.resources.displayMetrics.density * dpValue + 0.5f).toInt()
}
fun dp2px_F(context: Context, dpValue: Int): Float {
    return (context.resources.displayMetrics.density * dpValue + 0.5f).toFloat()
}